import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="RootTry") 
public class Foo {
	
	public static void main(String[] args) {
		Goo g = null;
		Foo f = new Foo();
		f.mBar = 345;
		f.ark = "a b  c</arr>";
		f.aarr = new String[]{"d  fg","dfg","d   fg","a b  c</arr>"};
		f.mlist = Arrays.asList(f.aarr);
		f.mmap = new HashMap<>();
		for(int i=0;i<1000;i++)
			f.mmap.put(i, f.aarr[i % f.aarr.length]);
		
		Foo f2 = null;
		try {
//			marshal(f, System.out);
			System.out.println();
			
			ByteArrayOutputStream outStream = new ByteArrayOutputStream(1024);
			MarshelUtil.marshal(f, outStream);
			String xmlString = outStream.toString();
			System.out.println(xmlString);
			f2 = MarshelUtil.unmarshal(new ByteArrayInputStream(xmlString.getBytes()), Foo.class);
			g = MarshelUtil.unmarshal(new ByteArrayInputStream(xmlString.getBytes()), Goo.class);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		System.out.println("f.aarr.length = " + f.aarr.length);
		System.out.println("f.mlist.size() = " + f.mlist.size());
		System.out.println("f.mmap.size() = " + f.mmap.size());
		System.out.println();
		System.out.println("f2.aarr.length = " + f2.aarr.length);
		System.out.println("f2.mlist.size() = " + f2.mlist.size());
		System.out.println("f2.mmap.size() = " + f2.mmap.size());
		System.out.println();
		System.out.println("g.aarr.length = " + g.aarr.length);
		System.out.println("g.mlist.size() = " + g.mlist.size());
		System.out.println("g.mmap.size() = " + g.mmap.size());
		
		System.out.println(f.mlist.equals(f2.mlist));
		System.out.println("done");
	}

	@XmlElement(name="Bar")
	public int mBar;
	
	@XmlElement(name="blah")
	protected String ark;
	
//	@XmlList
	@XmlElement(name="arr")
	private String[] aarr;
	
//	@XmlList
	@XmlElement(name="alist")
	private List<String> mlist;
	
//	@XmlList
	@XmlElement(name="amap")
	private HashMap<Integer, String> mmap;

}